<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	request.setCharacterEncoding("UTF-8");
	response.setContentType("text/html;charset=UTF-8");
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	String path = request.getContextPath();
%>
<html lang="zh-cn">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title></title>  
    <link rel="stylesheet" href="<%=path %>/admin/css/pintuer.css">
    <link rel="stylesheet" href="<%=path %>/admin/css/admin.css">
    <script src="<%=path %>/admin/js/jquery.js"></script>
    <script src="<%=path %>/admin/js/pintuer.js"></script>  
		
</head>
<body>
<form method="post" action="<%=path %>/planManage/deletePlan" id="listform">
  <div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 客户订单</strong> <a href="" style="float:right; display:none;">添加字段</a></div>
    <div class="padding border-bottom">
      <ul class="search" style="padding-left:10px;">
        <li>
          <input type="text" placeholder="请输入搜索关键字" name="keywords" id="keywords" class="input" style="width:250px; line-height:17px;display:inline-block" />
          <a href="javascript:void(0)" class="button border-main icon-search" onclick="changesearch()" > 搜索</a></li>
      </ul>
    </div>
    <table class="table table-hover text-center">
    <div id="vos">
      <tr class="thead">
        <th style="text-align:left; padding-left:20px;width:8%">ID</th>
        <th style="width:10%">姓名</th>
        <th style="width:10%">联系方式</th>
        <th style="width:10%">案例模板</th>
        <th style="width:20%">需求描述</th>
        <th width="10%">订单时间</th>
       <!--  <th width="10%">状态</th>
        <th width="310">操作</th> -->
      </tr>
  </div>
       <volist name="list" id="vo"> 
        	        
      	 <c:forEach items="${orderList }" var="list" varStatus="s">
              	<tr class="fir">
		          <td id="planId" style="text-align:left; padding-left:20px;"><%-- <input type="checkbox" name="id[]" value="${list.orderId}" /> --%>
		           ${list.orderId}</td>
		          <td>${list.orderName }</td>
		          <td>${list.orderPhone }</td>
		          <td>${list.orderPlanTitle }</td>
		          <td>${list.orderDescription }</td>
		          <td><fmt:formatDate value="${list.orderCreateTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
		         <!--  <td >a</td>
		          <td><div class="button-group" style="height:44px;"> <a class="button border-main" onclick="javascript:update(this)"><span class="icon-edit"></span> 修改</a>  </div></td> -->
		        </tr>	
              </c:forEach>
              
   		 </volist>
     <%--  <tr>
        <td style="text-align:left; padding:19px 0;padding-left:20px;"><input type="checkbox" id="checkall"/>
          全选 </td>
        <td colspan="7" style="text-align:left;padding-left:20px;"><c:if test="${admin.adRoleNo eq 'HIGH' || admin.adRoleNo eq 'AUDIT' }"><a href="javascript:void(0)" class="button border-green icon-edit" style="padding:5px 15px;margin-right:15px;" onclick="AuditSelect()"> 审核通过</a></c:if><a href="javascript:void(0)" class="button border-red icon-trash-o" style="padding:5px 15px;" onclick="DelSelect()"> 删除</a> 
       
      <tr> --%>
        <td colspan="8">
	        <div class="pagelist"> 
	        	 <a id="up" href="javascript:upPage();">上一页</a>
	        	 <c:forEach begin="1" end="${pageSum }" step="1"  var="list" varStatus="s">
	        	 <c:if test="${list eq pageNo }"><span class="current">${list }</span></c:if>
	        	 <c:if test="${list ne pageNo }"><a class="next"  href="javascript:void(0);" onclick="toPage(this);">${list }</a></c:if>
		         <!-- <span class="current">1</span><a  href="">2</a><a href="">3</a> -->
		         </c:forEach>
		         <a href="javascript:nextPage();">下一页</a>
		         <!-- <a href="">尾页</a>  -->
	         </div>
         </td>
      </tr>
    </table>
  </div>
</form>
<script type="text/javascript" src="<%=path%>/admin/js/layer/layer.js" ></script>
<script type="text/javascript">
	var paths = '<%=path %>';
 	var pageNo = $(".current").text();
 	$(".tag").change(function(){
 		changesearch();
 	});
 	$(function(){
 		var dTag = '${deleteTag}';
 		if(dTag >= 1){
 			layer.msg('删除操作成功！');
 		}else if(dTag == -1){
 			layer.msg('系统忙,请稍后重试...');
 		}
 		var aTag = '${auditTag}';
 		if(aTag >= 1){
 			layer.msg('审核操作成功！');
 		}else if(aTag == -1){
 			layer.msg('系统忙,请稍后重试...');
 		}
 		var uTag = '${upTag}';
 		if(uTag >= 1){
 			layer.msg('修改操作成功！');
 		}else if(uTag == -1){
 			layer.msg('系统忙,请稍后重试...');
 		}
 	});
//搜索
function changesearch(){	
		var tag = $("#hangye").val()+","+$("#jieri").val()+","+$("#gongneng").val();
		var key = $("#keywords").val();
		newPage(1,key,tag);
		
}
function nextPage(){
	var pageSum = '${pageSum }';
	pageNo = $(".current").text();
	pageNo = parseInt(pageNo);
	if(pageNo<pageSum){
		pageNo+=1;
	}
	var tag = $("#hangye").val()+","+$("#jieri").val()+","+$("#gongneng").val();
	var key = $("#keywords").val();
	newPage(pageNo,key,tag);
}
function upPage(){
	pageNo = $(".current").text();
	pageNo = parseInt(pageNo);
	if(pageNo>1){
		pageNo-=1;
	}
	var tag = $("#hangye").val()+","+$("#jieri").val()+","+$("#gongneng").val();
	var key = $("#keywords").val();
	newPage(pageNo,key,tag);
}
function toPage(obj){
	var tag = $("#hangye").val()+","+$("#jieri").val()+","+$("#gongneng").val();
	var key = $("#keywords").val();
	pageNo = $(obj).text();
	pageNo = parseInt(pageNo);
	newPage(pageNo,key,tag);
}
//newPage or search
function newPage(pageNo,key,tag){
	var params = new Object();
	params.pageNo = pageNo-1;
	params.key = key;
	if(tag ==',,'){
		tag = '';
	}
	params.tag = tag;
	$.ajax({ 
		type:"post",
		url:"<%=path %>/orderManage/newPage",
		data:params,
		dataType: "json",  
        timeout: 10000,  
        cache: false,  
        error: function(){
        	alert("系统忙...");
        },
        success: function(data){
        	var json=eval(data);
        	pageNo = json.pageNo;
        	pageSum = json.pageSum;
        	var htmls = "";
       	 $.each(json.orderList, function (index, item) {  
             //循环获取数据   
             var record =new Object(); 
            	 record.id=item.orderId;
            	 record.name=item.orderName;
            	 record.phone=item.orderPhone;
            	 record.plantitle=item.orderPlanTitle;
            	 record.description=item.orderDescription;
            	 record.createtime=item.orderCreateTime;
 
               htmls += '<tr class="fir">'
					+'<td id="planId" style="text-align:left; padding-left:20px;"><input type="checkbox" name="id[]" value="'+record.id+'" />'+record.id+'</td>'
					+'<td >'+record.name+'</td>'
					+'<td>'+record.phone+'</td>'
					+'<td>'+record.plantitle+'</td>'
					+'<td>'+record.description+'</td>'
					+'<td>'+getNowFormatDate(record.createtime)+'</td>';
					/* +'<td';
					if(record.audit =='已审核'){
						htmls+=' style="color:#009100;" ';
					}
				htmls+='>'+record.audit+'</td>'
					+'<td><div class="button-group" style="height:44px;"> ';
				if(record.audit =='未审核'){
					htmls+='<a class="button border-main" onclick="javascript:update(this)"><span class="icon-edit"></span> 修改</a>';
				} */
				htmls+=' </div></td>';
				htmls+='</tr>';
         });
       	 $(".fir").remove();
       	 $(".thead").after(htmls);
       	 //改变页数
       	 $(".next").remove();
       	 $(".current").remove();
       	 var inner = "";
       	 for (var i = 1; i <= pageSum; i++) {
       		 var nowPage = "";
			if(i == pageNo+1){
				nowPage = '<span class="current">'+i+'</span>';
			}else{
				nowPage = '<a class="next"  href="javascript:void(0);" onclick="toPage(this);">'+i+'</a>';
			}
			inner +=nowPage;
		}
       	 $("#up").after(inner);
        }   
	});
}
//修改
function update(obj){
	var id = $(obj).closest(".fir").find("#planId").text().trim();
	$.ajax({ 
		type:"post",
		url:"<%=path %>/planManage/toUpdate",
		data:{planId:id},  
        timeout: 10000,  
        cache: false,  
        error: function(){
        	alert("系统忙...");
        },
        success: function(data){	
        	window.location.href="<%=path %>/planManage/update";
        }
       });
}
//单个删除
function del(id,mid,iscid){
	if(confirm("您确定要删除吗?")){
		
	}
}

//全选
$("#checkall").click(function(){ 
  $("input[name='id[]']").each(function(){
	  if (this.checked) {
		  this.checked = false;
	  }
	  else {
		  this.checked = true;
	  }
  });
})

//批量删除
function DelSelect(){
	$("#listform").attr("action",paths+"/planManage/deletePlan");
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		var t=confirm("您确认要删除选中的内容吗？");
		if (t==false) return false;		
		$("#listform").submit();		
	}
	else{
		alert("请选择您要删除的内容!");
		return false;
	}
}

//批量审核
function AuditSelect(){
	$("#listform").attr("action",paths+"/planManage/auditSelect");
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		var t=confirm("您确认审核通过选中的内容吗？");
		if (t==false) return false;		
		$("#listform").submit();		
	}
	else{
		alert("请选择您审核通过的内容!");
		return false;
	}
}

//批量排序
function sorts(){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){	
		
		$("#listform").submit();		
	}
	else{
		alert("请选择要操作的内容!");
		return false;
	}
}


//批量首页显示
function changeishome(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		
		$("#listform").submit();	
	}
	else{
		alert("请选择要操作的内容!");		
	
		return false;
	}
}

//批量推荐
function changeisvouch(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		
		
		$("#listform").submit();	
	}
	else{
		alert("请选择要操作的内容!");	
		
		return false;
	}
}

//批量置顶
function changeistop(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){		
		
		$("#listform").submit();	
	}
	else{
		alert("请选择要操作的内容!");		
	
		return false;
	}
}


//批量移动
function changecate(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){		
		
		$("#listform").submit();		
	}
	else{
		alert("请选择要操作的内容!");
		
		return false;
	}
}

//批量复制
function changecopy(o){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){	
		var i = 0;
	    $("input[name='id[]']").each(function(){
	  		if (this.checked==true) {
				i++;
			}		
	    });
		if(i>1){ 
	    	alert("只能选择一条信息!");
			$(o).find("option:first").prop("selected","selected");
		}else{
		
			$("#listform").submit();		
		}	
	}
	else{
		alert("请选择要复制的内容!");
		$(o).find("option:first").prop("selected","selected");
		return false;
	}
}
 function getNowFormatDate(time) {
	    var date = new Date(time);
	    var seperator1 = "-";
	    var seperator2 = ":";
	    var year = date.getFullYear();
	    var month = date.getMonth() + 1;
	    var strDate = date.getDate();
	    if (month >= 1 && month <= 9) {
	        month = "0" + month;
	    }
	    if (strDate >= 0 && strDate <= 9) {
	        strDate = "0" + strDate;
	    }
	    var h = 0;
	    if (date.getHours() >= 0 && date.getHours() <= 9) {
	        h = "0" + date.getHours();
	    }else{
	    	h = date.getHours();
	    }
	    var m = 0;
	    if (date.getMinutes() >= 0 && date.getMinutes() <= 9) {
	        m = "0" + date.getMinutes();
	    }else{
	    	m = date.getMinutes();
	    }
	    var s = 0;
	    if (date.getSeconds() >= 0 && date.getSeconds() <= 9) {
	        s = "0" + date.getSeconds();
	    }else{
	    	s = date.getSeconds();
	    }
	    var currentdate = year + seperator1 + month + seperator1 + strDate
	            + " " + h + seperator2 + m
	            + seperator2 + s;
	    return currentdate;
	}

</script>
</body>
 <script type="text/javascript" src="<%=path%>/admin/js/layer/layer.js" ></script>
<script type="text/javascript">

</script>
</html>